const axios = require('axios')

function createPythonInterface(url) {
    return async function (params) {
        const resp = await axios({
            method: 'post',
            url: `http://127.0.0.1:5000/${url}`,
            data: params
        })
        if (resp.status == 200) {
            return resp.data
        }
        throw new Error('请求python接口失败: ' + resp.status)
    }
}

module.exports = {createPythonInterface}
